/**
 * Created by zzl on 2016/5/5.
 */
$(document).ready(function(){
    var $user_name =document.getElementsByClassName('cas');
    var $subMit = document.getElementsByClassName('cet');
    for (var i = 0, j = $subMit.length; i < j; i++){
        //scope2 作用域2
        var $set = $subMit[i];
        $set.onclick = function(i){
            //scope3 作用域3
            return function(){
                //scope4 作用域4
                console.log(i);
                var e=i;
                if ( e<$user_name.length){
                    var $key = $user_name[i];
                    if($key.value ==''){
                        layer.alert('字数不能超过30个字', {
                            icon: 2,
                            shade: 0.2
                        });
                        return false;
                    }
                    else if($key.value !=''&& $key.value.length >30){
                        layer.alert('字数不能超过30个字', {
                            icon: 2,
                            shade: 0.2
                        });
                        return false;
                    }
                }
            }
        }(i)
    }
});

function checkAddConfig(){
    var $user_name =$('#val1').val();
    if($user_name ==''||( $user_name !='' && $user_name.length >30 )){
        layer.alert('字数不能超过30个字', {
            icon: 2,
            shade: 0.2
        });
        return false;
    }
}